package cn.jlonely.xyhx.app.service.impl;


import cn.jlonely.xyhx.app.mapper.AppReviewMapper;
import cn.jlonely.xyhx.app.service.AppReviewService;
import cn.jlonely.xyhx.pojo.Review;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class AppReviewServiceImpl implements AppReviewService {
    @Autowired
    private AppReviewMapper appReviewMapper;


    @Override
    public List<Review> getReviewInfo(Integer id) {
        return appReviewMapper.getReviewInfo(id);
    }

    /**
     * 加入活动
     * @param review
     */
    @Override
    public void creatReview(Review review)  throws Exception {
        boolean noReview = appReviewMapper.selectById(review.getRankingId(), review.getUserId());
        if (noReview) {
            throw new Exception ("您已经参与过该活动了");
        }
        appReviewMapper.creatReview(review);
    }
}
